package tech.yunqian.slim.project.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ActionType
{
    SPECIFIC_FUNCTION(0, "定制功能"),
    API(1, "API调用"),
    RPC(2, "指令下发");

    private static final Map<Integer, ActionType> BY_CODE = new HashMap<>();
    private static final Map<String, ActionType> BY_LABEL = new HashMap<>();
    private static final List<String> LABELS = new ArrayList<>();
    static {
        for (ActionType co : values()) {
            BY_CODE.put(co.code, co);
            BY_LABEL.put(co.label, co);
            LABELS.add(co.label);
        }
    }

    private Integer code;
    private String label;

    public static ActionType valueOfCode(Integer code) {
        return BY_CODE.get(code);
    }

    public static ActionType valueOfLabel(String label) {
        return BY_LABEL.get(label);
    }

    public static List<String> labels() {
        return LABELS;
    }
}
